package org.example.book.common.result;

import lombok.Data;

import java.util.Map;

@Data
public class Result<T> {
    private Integer code;
    private String message;
    private T data;

//    public static <T> Result<T> success(T data){
//        Result<T> rest=new Result<>();
//        rest.setCode(200);
//        rest.setMessage("成功");
//        rest.setData(data);
//        return rest;
//    }

    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMessage("成功");
        result.setData(data);  // 确保正确设置data字段
        return result;
    }

    public static <T> Result<T> fail(String message) {
        Result<T> rest = new Result<>();
        rest.setCode(500);
        rest.setMessage(message);
        return rest;
    }
}
